#include "common.hpp"
#include "Socket.hpp"
#include "protocol.hpp"
#include "client_TCP.hpp"



uint16_t server_port;
std::string server_ip;
int socket_fd;

int main(int argc, char* argv[])
{
    //./client_TCP [server_port] [server_ip]  
    if(argc != 3)
    {
        std::cout << "usage: " << argv[0] << " [server_port] [server_ip]" << std::endl;
        exit(USAGE_ERR);
    }

    server_port = static_cast<uint16_t>(std::stoi(argv[1]));
    server_ip = argv[2];

    std::unique_ptr<protocol> ptl_p = std::make_unique<protocol>();

    std::unique_ptr<client_tcp> ct_p = std::make_unique<client_tcp>(server_port, server_ip, [&ptl_p](std::shared_ptr<Socket>& sock_p, const Inet_Addr& server)
                                                                                            {
                                                                                                ptl_p->send_request_and_receive_response(sock_p, server);
                                                                                            }
                                                                   );
    ct_p->start();


    return 0;
}